//
//  MVTableViewCell.m
//  SunXi
//
//  Created by dllo on 15/12/3.
//  Copyright © 2015年 大远. All rights reserved.
//

#import "MVTableViewCell.h"

@implementation MVTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createData];
    }
    return self;
}

- (void)createData{
    
    self.tuImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.tuImageView];
    
    self.titLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.titLabel];
    self.titLabel.textColor = [UIColor whiteColor];
    self.titLabel.font = [UIFont systemFontOfSize:20];
    
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.tuImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.contentView).with.insets(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
    
    [self.titLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.tuImageView).with.insets(UIEdgeInsetsMake(CHEIGHT / 10 * 7, CWIDTH / 20, CHEIGHT / 10, CWIDTH / 20));
    }];
    
}

- (void)setModel:(MVmodel *)model {
    if (_model != model) {
        
        _model = [model retain];
        
        self.titLabel.text = model.title;
        
        [self.tuImageView sd_setImageWithURL:[NSURL URLWithString:_model.pimg] placeholderImage:[UIImage imageNamed:@"zan"]];
        
        
    }
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
